//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "MarketModelMultiProductCashFlow.h"
using namespace Cephei::QL::Models::Marketmodels;
#undef HANDLE
#undef ABSTRACT
#define STRUCT
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow (UInt64 TimeIndex, Double Amount) 
{
	_pSpinlock = new boost::detail::spinlock ();
    try
    {
#ifdef HANDLE
        _phMarketModelMultiProductCashFlow = NULL;
#endif
        QuantLib::Size _TimeIndex = (QuantLib::Size)ValueHelper::Convert (TimeIndex);
        QuantLib::Real _Amount = (QuantLib::Real)ValueHelper::Convert (Amount);
        _ppMarketModelMultiProductCashFlow = new boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow> (new QuantLib::MarketModelMultiProductCashFlow ( _TimeIndex,  _Amount ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow () 
{
	_pSpinlock = new boost::detail::spinlock ();
    try
    {
#ifdef HANDLE
        _phMarketModelMultiProductCashFlow = NULL;
#endif
        _ppMarketModelMultiProductCashFlow = new boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow> (new QuantLib::MarketModelMultiProductCashFlow ( ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow (boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>& childNative, Object^ owner) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phMarketModelMultiProductCashFlow = NULL;
#endif
	_ppMarketModelMultiProductCashFlow = &childNative;
    
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow (QuantLib::MarketModelMultiProductCashFlow& childNative, Object^ owner) 
{
#ifdef HANDLE
	_phMarketModelMultiProductCashFlow = NULL;
#endif
	_ppMarketModelMultiProductCashFlow = new boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow> (&childNative);
    
    _MarketModelMultiProductCashFlowOwner = owner;
    
}

Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow (CMarketModelMultiProductCashFlow^ copy) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phMarketModelMultiProductCashFlow = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppMarketModelMultiProductCashFlow = new boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow> (copy->GetShared());
        
    }
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow (System::Type^ t) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phMarketModelMultiProductCashFlow = NULL;
#endif
	if (!t->IsSubclassOf(CMarketModelMultiProductCashFlow::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow (QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>& childNative, Object^ owner)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phMarketModelMultiProductCashFlow = &childNative;
	_ppMarketModelMultiProductCashFlow = &static_cast<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>(childNative.currentLink());
    
    _MarketModelMultiProductCashFlowOwner = owner;
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow (QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow> childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phMarketModelMultiProductCashFlow = &childNative;
	_ppMarketModelMultiProductCashFlow = &static_cast<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>(childNative.currentLink());
    
}
#endif
#ifdef STRUCT
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::CMarketModelMultiProductCashFlow (QuantLib::MarketModelMultiProductCashFlow childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phMarketModelMultiProductCashFlow = NULL;
#endif
	_ppMarketModelMultiProductCashFlow = new boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow> (new QuantLib::MarketModelMultiProductCashFlow (childNative));
    
}
#endif

Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::~CMarketModelMultiProductCashFlow ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
        _pSpinlock = NULL;
    }
    if (_ppMarketModelMultiProductCashFlow != NULL)
    {
	    delete _ppMarketModelMultiProductCashFlow;
        _ppMarketModelMultiProductCashFlow = NULL;
    }
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::!CMarketModelMultiProductCashFlow ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
    }
    if (_ppMarketModelMultiProductCashFlow != NULL)
    {
	    delete _ppMarketModelMultiProductCashFlow;
    }
}
QuantLib::MarketModelMultiProductCashFlow& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::GetReference ()
{
    if (_ppMarketModelMultiProductCashFlow == NULL) throw gcnew NativeNullException ();
	return **_ppMarketModelMultiProductCashFlow;
}
boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::GetShared ()
{
    if (_ppMarketModelMultiProductCashFlow == NULL) throw gcnew NativeNullException ();
	return *_ppMarketModelMultiProductCashFlow;
}
QuantLib::MarketModelMultiProductCashFlow* Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::GetPointer ()
{
    if (_ppMarketModelMultiProductCashFlow == NULL) throw gcnew NativeNullException ();
	return &**_ppMarketModelMultiProductCashFlow;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::GetHandle ()
{
	if (_phMarketModelMultiProductCashFlow == NULL)
	{
		_phMarketModelMultiProductCashFlow = new Handle<QuantLib::MarketModelMultiProductCashFlow> (*_ppMarketModelMultiProductCashFlow);
	}
	return *_phMarketModelMultiProductCashFlow;
}
#endif
bool Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow::HasNative () 
{
	return (_ppMarketModelMultiProductCashFlow != NULL);
}

Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::CMarketModelMultiProductCashFlowVector ()
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::~CMarketModelMultiProductCashFlowVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
	_pVValue = NULL;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
	_pVBoost = NULL;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
	_pVHand = NULL;
#endif
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::!CMarketModelMultiProductCashFlowVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
#endif
}
#ifdef STRUCT
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::CMarketModelMultiProductCashFlowVector (std::vector<QuantLib::MarketModelMultiProductCashFlow>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = &vec;
	_owner = owner;
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::CMarketModelMultiProductCashFlowVector (std::vector<QuantLib::MarketModelMultiProductCashFlow> vec)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = new std::vector<QuantLib::MarketModelMultiProductCashFlow> (vec);
}
#endif
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::CMarketModelMultiProductCashFlowVector (std::vector<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVBoost = &vec;
	_owner = owner;
}
#ifdef HANDLE
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::CMarketModelMultiProductCashFlowVector (std::vector<QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVHand = &vec;
	_owner = owner;
}
#endif

int Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::Count::get ()
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
		return _pVValue->size();
	}
#endif    
	if (_pVBoost != NULL)
	{
		return _pVBoost->size ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		return _pVHand->size ();
	}
#endif
	return 0;		// should never happen
}
Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::default::get (int index) 
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
    	if ((size_t)index >= _pVValue->size()) throw gcnew RangeException ();
		QuantLib::MarketModelMultiProductCashFlow& native = (*_pVValue)[index];
		return gcnew CMarketModelMultiProductCashFlow (native, this);
	}
#endif    
	if (_pVBoost != NULL)
	{
    	if ((size_t)index >= _pVBoost->size()) throw gcnew RangeException ();
		QuantLib::MarketModelMultiProductCashFlow& native = *(*_pVBoost)[index];
		return gcnew CMarketModelMultiProductCashFlow (native, this);
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
    	if ((size_t)index >= _pVHand->size()) throw gcnew RangeException ();
		QuantLib::MarketModelMultiProductCashFlow& native = *((*_pVHand)[index].currentLink ());
		return gcnew CMarketModelMultiProductCashFlow (native, this);
	}
#endif
	return nullptr;		// can never be the case
}
void Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::default::set (int index, Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^ value) 
{
#ifdef STRUCT
	if (_pVValue != NULL)
	{
		if (_pVValue->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVValue->size() < (size_t)index)
			{
				throw gcnew RangeException ();
			}
			_pVValue->push_back (dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetReference ());
		}
        else
        {
            QuantLib::MarketModelMultiProductCashFlow& c = (*_pVValue)[index];
            c = dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetReference ();
        }
	}
#endif   
	if (_pVBoost != NULL)
	{
		if (_pVBoost->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVBoost->size() < (size_t)index)
			{
				throw gcnew RangeException ();
			}
			_pVBoost->push_back (dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetShared ());
		}
		boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>& c = (*_pVBoost)[index];
		c = dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetShared ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		if (_pVHand->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVHand->size() < (size_t)index)
			{
				throw gcnew RangeException ();
			}
			_pVHand->push_back (QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow> ());
		}
		QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>& c = (*_pVHand)[index];
		boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>& b = static_cast<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>(c.currentLink());
		b = dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetShared ();
	}
#endif
}
Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::CItem::get (int index) 
{
	return CellBuilder::Instance->Create<IMarketModelMultiProductCashFlow^> (dynamic_cast<IMarketModelMultiProductCashFlow^>(default[index]));
}

void Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::CItem::set (int index, Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ value) 
{
	default[index] = safe_cast<IMarketModelMultiProductCashFlow^>(value->Value);
}
#ifdef STRUCT
std::vector<QuantLib::MarketModelMultiProductCashFlow>& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::GetReference ()
{
	 return *_pVValue;
}
#endif

std::vector<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::GetShared ()
{
	return *_pVBoost;
}

#ifdef HANDLE
std::vector<QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>>& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::GetHandle ()
{
	return *_pVHand;
}
#endif
bool Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowVector::PrepareFeature (NativeFeature feature)
{
	switch (feature)
	{
#ifdef STRUCT
		case NativeFeature::Value :
			if (_pVValue == NULL)
			{
				_pVValue = new std::vector<QuantLib::MarketModelMultiProductCashFlow> ();
				return true;
			}
			break;
#endif
        case NativeFeature::shared_ptr :
			if (_pVBoost == NULL)
			{
				_pVBoost = new std::vector<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>> ();
				return true;
			}
			break;
#ifdef HANDLE
        case NativeFeature::Handle :
            if (_pVHand == NULL)
            {
                _pVHand = new std::vector<QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>> ();
                return true;
            }
            break;
#endif
	}
	return false;
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CMarketModelMultiProductCashFlowMatrix ()
{
#ifdef STRUCT
	_pVValue = NULL;
#endif    
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
}
#ifdef STRUCT
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CMarketModelMultiProductCashFlowMatrix (std::vector<std::vector<QuantLib::MarketModelMultiProductCashFlow>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif    
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = &vec;
	_owner = owner;
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CMarketModelMultiProductCashFlowMatrix (std::vector<std::vector<QuantLib::MarketModelMultiProductCashFlow>> vec)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif    
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = new std::vector<std::vector<QuantLib::MarketModelMultiProductCashFlow>> (vec);
}
#endif
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CMarketModelMultiProductCashFlowMatrix (std::vector<std::vector<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif    
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVBoost = &vec;
	_owner = owner;
}
#ifdef HANDLE
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CMarketModelMultiProductCashFlowMatrix (std::vector<std::vector<QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif    
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVHand = &vec;
	_owner = owner;
}
#endif
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::~CMarketModelMultiProductCashFlowMatrix ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
	_pVValue = NULL;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
	_pVBoost = NULL;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
	_pVHand = NULL;
#endif
}
Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::!CMarketModelMultiProductCashFlowMatrix ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
	_pVValue = NULL;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
	_pVBoost = NULL;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
	_pVHand = NULL;
#endif
}
int Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::Count::get ()
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
		return _pVValue->size();
	}
#endif    
	if (_pVBoost != NULL)
	{
		return _pVBoost->size ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		return _pVHand->size ();
	}
#endif
	return 0;		// should never happen
}
Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::default::get (int x, int y) 
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
		if ((size_t)x >= _pVValue->size() || (size_t)y >= (*_pVValue)[x].size()) throw gcnew RangeException ();
		QuantLib::MarketModelMultiProductCashFlow& native = (*_pVValue)[x][y];
		return gcnew CMarketModelMultiProductCashFlow (native, this);
	}
#endif    
	if (_pVBoost != NULL)
	{
		if ((size_t)x >= _pVBoost->size() || (size_t)y >= (*_pVBoost)[x].size()) throw gcnew RangeException ();
		QuantLib::MarketModelMultiProductCashFlow& native = *(*_pVBoost)[x][y];
		return gcnew CMarketModelMultiProductCashFlow (native, this);
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		if ((size_t)x >= _pVHand->size() || (size_t)y >= (*_pVHand)[x].size()) throw gcnew RangeException ();
		QuantLib::MarketModelMultiProductCashFlow& native = *((*_pVHand)[x][y].currentLink ());
		return gcnew CMarketModelMultiProductCashFlow (native, this);
	}
#endif
	return nullptr;		// can never be the case
}
void Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::default::set (int x, int y, Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^ value) 
{
#ifdef STRUCT
	if (_pVValue != NULL)
	{
		if (_pVValue->size() <= (size_t)x)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVValue->size()-1 < (size_t)x) throw gcnew RangeException ();

			_pVValue->push_back (std::vector<QuantLib::MarketModelMultiProductCashFlow>());
		}
		if ((*_pVValue)[x].size() <= (size_t)y)
		{
			if ((*_pVValue)[x].size() < (size_t)y) throw gcnew RangeException ();

			(*_pVValue)[x].push_back (dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetReference ());
		}
        else
        {    
            QuantLib::MarketModelMultiProductCashFlow& c = (*_pVValue)[x][y];
            c = dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetReference ();
        }
	}
#endif    
	if (_pVBoost != NULL)
	{
		if (_pVBoost->size() <= (size_t)x)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVBoost->size()-1 < (size_t)x) throw gcnew RangeException ();

			_pVBoost->push_back (std::vector<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>());
		}
		if ((*_pVBoost)[x].size() <= (size_t)y)
		{
			if ((*_pVBoost)[x].size() < (size_t)y) throw gcnew RangeException ();

			(*_pVBoost)[x].push_back (dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetShared ());
		}
        else
        {
            boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>& c = (*_pVBoost)[x][y];
            c = dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetShared ();
        }
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		if (_pVHand->size() <= (size_t)x)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVHand->size()-1 < (size_t)x) throw gcnew RangeException ();

			_pVHand->push_back (std::vector<QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>>());
		}
		if ((*_pVHand)[x].size() <= (size_t)y)
		{
			if ((*_pVHand)[x].size() < (size_t)y) throw gcnew RangeException ();

			(*_pVHand)[x].push_back (QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow> ());
		}
		QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>& c = (*_pVHand)[x][y];
		boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>& b = static_cast<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>(c.currentLink());
		b = dynamic_cast<CMarketModelMultiProductCashFlow^>(value)->GetShared ();
	}
#endif
}
Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CItem::get (int x, int y) 
{
	return CellBuilder::Instance->Create<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^> (dynamic_cast<IMarketModelMultiProductCashFlow^>(default[x,y]));
}
void Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CItem::set (int x, int y, Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ value)
{
	default[x,y] = safe_cast<IMarketModelMultiProductCashFlow^>(value->Value);
}

#ifdef STRUCT
std::vector<std::vector<QuantLib::MarketModelMultiProductCashFlow>>& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::GetReference ()
{
	 return *_pVValue;
}
#endif

std::vector<std::vector<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>>& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::GetShared ()
{
	return *_pVBoost;
}

#ifdef HANDLE
std::vector<std::vector<QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>>>& Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::GetHandle ()
{
	return *_pVHand;
}
#endif
bool Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::PrepareFeature (NativeFeature feature)
{
	switch (feature)
	{
#ifdef STRUCT
		case NativeFeature::Value :
			if (_pVValue == NULL)
			{
				_pVValue = new std::vector<std::vector<QuantLib::MarketModelMultiProductCashFlow>> ();
				return true;
			}
			break;
#endif            
		case NativeFeature::shared_ptr :
			if (_pVBoost == NULL)
			{
				_pVBoost = new std::vector<std::vector<boost::shared_ptr<QuantLib::MarketModelMultiProductCashFlow>>> ();
				return true;
			}
			break;
#ifdef HANDLE
		case NativeFeature::Handle :
			if (_pVHand == NULL)
			{
				_pVHand = new std::vector<std::vector<QuantLib::Handle<QuantLib::MarketModelMultiProductCashFlow>>> ();
				return true;
			}
			break;
#endif
	}
	return false;
}
INativeVector<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CreateVector () 
{
	return gcnew CMarketModelMultiProductCashFlowVector ();
}
INativeVector<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlowMatrix::CreateCellVector ()
{
	return gcnew CMarketModelMultiProductCashFlowVector ();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::Create (UInt64 TimeIndex, Double Amount)
{
    return gcnew CMarketModelMultiProductCashFlow ( TimeIndex,  Amount);
}
Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::Create ()
{
    return gcnew CMarketModelMultiProductCashFlow ();
}
/* <summary>Create a single dimension array of MarketModelMultiProductCashFlow that can be passed into other function </summary> */
IVector<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::CreateVector ()
 {
	 return gcnew CoVector<IMarketModelMultiProductCashFlow^> (gcnew CMarketModelMultiProductCashFlowVector ());
 }
IVector<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::CreateVector (System::Collections::Generic::IEnumerable<IMarketModelMultiProductCashFlow^>^ source)
 {
	 return gcnew CoVector<IMarketModelMultiProductCashFlow^> (source, gcnew CMarketModelMultiProductCashFlowVector ());
 }
/* <summary>Create a single dimension array of MarketModelMultiProductCashFlow with change events</summary> */
Cephei::Generic::ICell<IVector<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::CreateCellVector ()
 {
	 return CellBuilder::Instance->Create<IVector<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^> (gcnew CoCellVector<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^> (gcnew CMarketModelMultiProductCashFlowVector ()));
 }
Cephei::Generic::ICell<IVector<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::CreateCellVector (System::Collections::Generic::IEnumerable<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^ source)
 {
	 return CellBuilder::Instance->Create<IVector<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^> (gcnew CoCellVector<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^> (source, gcnew CMarketModelMultiProductCashFlowVector ()));
 }

/* <summary> Create a two dimension array of MarketModelMultiProductCashFlow that can be passed into other function </summary> */
Cephei::IMatrix<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::CreateMatrix ()
 {
	 return gcnew CoMatrix<IMarketModelMultiProductCashFlow^> (gcnew CMarketModelMultiProductCashFlowMatrix ());
 }
Cephei::IMatrix<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::CreateMatrix (System::Collections::Generic::IEnumerable<IVector<IMarketModelMultiProductCashFlow^>^>^ source)
 {
	 return gcnew CoMatrix<IMarketModelMultiProductCashFlow^> (source, gcnew CMarketModelMultiProductCashFlowMatrix ());
 }
/* <summary> Create a two dimension array of MarketModelMultiProductCashFlow with change events </summary> */
Cephei::Generic::ICell<Cephei::IMatrix<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::CreateCellMatrix ()
 {
	 return CellBuilder::Instance->Create<Cephei::IMatrix<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^> (gcnew CoCellMatrix<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^> (gcnew CMarketModelMultiProductCashFlowMatrix ()));
 }
Cephei::Generic::ICell<Cephei::IMatrix<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^>^ Cephei::QL::Models::Marketmodels::CMarketModelMultiProductCashFlow_Factory::CreateCellMatrix (System::Collections::Generic::IEnumerable<IVector<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^>^ source)
 {
	 return CellBuilder::Instance->Create<Cephei::IMatrix<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^>^> (gcnew CoCellMatrix<Cephei::Generic::ICell<Cephei::QL::Models::Marketmodels::IMarketModelMultiProductCashFlow^>^> (source, gcnew CMarketModelMultiProductCashFlowMatrix ()));
 }

